package com.ruoyi.web.controller.system;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.pojo.*;
import com.ruoyi.system.service.SysTaskPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: zhangzhe
 * @Date: 2023/9/21
 */
@Api(tags = "1.1非常规任务")
@RestController
@RequestMapping("/system/taskplan")
public class SysTaskPlanController {

    @Resource
    SysTaskPlanService sysTaskPlanService;

    @ApiOperation("1.1.1添加任务计划（非常规）")
    @ApiOperationSupport(order = 1)
    @PostMapping("/addTaskPlan")
    public AjaxResult addTaskPlan(@RequestBody AddTaskPlanReq param) {
        return sysTaskPlanService.addTaskPlan(param);
    }

    @ApiOperation("1.1.2编辑任务计划（非常规）")
    @ApiOperationSupport(order = 2)
    @PostMapping("/editTaskPlan")
    public AjaxResult editTaskPlan(@RequestBody UpdateTaskPlanReq param) {
        return sysTaskPlanService.editTaskPlan(param);
    }

    @ApiOperation("1.1.3删除任务计划")
    @ApiOperationSupport(order = 3)
    @PostMapping("/deleteTaskPlan")
    public AjaxResult deleteTaskPlan(@RequestBody TaskPlanReq param) {
        return sysTaskPlanService.deleteTaskPlan(param.getId());
    }

    @ApiOperation("1.1.4发布非常规任务计划")
    @ApiOperationSupport(order = 4)
    @PostMapping("/publishTaskPlan")
    public AjaxResult publishTaskPlan(@RequestBody TaskPlanReq param) {
        return sysTaskPlanService.publishTaskPlan(param.getId());
    }

    @ApiOperation("1.1.5手动停止任务计划")
    @ApiOperationSupport(order = 5)
    @PostMapping("/stopTaskPlan")
    public AjaxResult stopTaskPlan(@RequestBody TaskPlanReq param) {
        return sysTaskPlanService.stopTaskPlan(param.getId());
    }

}
